package collectionFramework;

import java.util.LinkedList;
import java.util.ListIterator;

public class MyLinkedList {
	public static void main(String[] args) {
		LinkedList<Integer> l = new LinkedList<Integer>();
		l.add(10);
		l.add(80);
		l.add(60);
		l.add(15);
		l.add(30);
		System.out.println("List :" + l);
		l.add(2, 200);
		System.out.println("List :" + l);
		l.remove(1);
		System.out.println("List (removed ):" + l);
		System.out.println("First Element: " + l.getFirst());
		System.out.println("Last Element: " + l.getLast());
		l.removeFirst();
		System.out.println("List (First removed) :" + l);
		l.removeLast();
		System.out.println("List (Last removed) :" + l);

		ListIterator<Integer> lit = l.listIterator();

		System.out.println("Elements in Forward direction");
		while (lit.hasNext())
			System.out.println(lit.next());

		System.out.println("Elements in backward direction");
		while (lit.hasPrevious())
			System.out.println(lit.previous());
	}
}
